/*
 * @Author: gyc
 * @Date: 2020-06-11 15:50:17
 * @LastEditTime: 2020-07-18 10:16:02
 * @Description: Nuxt测试版
 */
'use strict';

const Controller = require('egg').Controller;

const OSS = require('../../config/oss');
class ImgController extends Controller {
    async getSwiperUrl() {
        const {
            ctx
        } = this
        const module = ctx.query.module
        const swiperUrl = await ctx.service.img.findSwiperImg(module)
        ctx.body = {
            data: swiperUrl
        }
    }
    //图片上传
    async upLoadImg() {
        const {
            ctx
        } = this
        const file = ctx.request.files;
        console.log(file.length)
        file.forEach(function (e) {
            OSS.put('gyc/' + e.field + '/' + e.filename, e.filepath)
        })
        ctx.body = {
            data: '1'
        }
    }
    //首页vedio图片
    async getVedioImg() {
        const {
            ctx
        } = this
        const list =await ctx.service.img.findVedioImg()
        ctx.body = {
            data: list
        }
    }
        //首页热门咨询
        async getHotImg() {
            const {
                ctx
            } = this
            const list =await ctx.service.img.findHotImg()
            ctx.body = {
                data: list
            }
        }
}

module.exports = ImgController